package com.rmt.www.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.rmt.www.dao.ProjectDao;
import com.rmt.www.dao.UserDao;
import com.rmt.www.service.AdminManageUserService;
import com.rmt.www.vo.Project;
import com.rmt.www.vo.User;


public class AddUserAction extends ActionSupport{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	private String username;
	private String password;
	private String type;
	private List<User> userList;
	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	private AdminManageUserService adminManageUserService;
	
	public AdminManageUserService getAdminManageUserService() {
		return adminManageUserService;
	}

	public void setAdminManageUserService(
			AdminManageUserService adminManageUserService) {
		this.adminManageUserService = adminManageUserService;
	}

	public String execute(){
		User user = new User();
		user.setType(type);
		user.setPassword(password);
		user.setName(username);
		adminManageUserService.addNewUser(user);
		userList = adminManageUserService.getUserList();
		return "success";
	}
}
